﻿<?xml version="1.0" encoding="utf-8"?>
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="217" MadCap:lastWidth="1064">
    <head>
    </head>
    <body>
        <h1>Sharing Code</h1>
        <p>One of the key advantages of using a Dynamic Link Library (DLL) rather than a traditional static library linked to an application at build time is that the code, data and resources in the DLL can be shared by multiple applications at runtime. This is because just a single copy of the DLL is loaded into memory. This can give a significant saving over static libraries in which duplicate copies of the same read-only code, data and resources need to be loaded into each application’s memory space.</p>
        <p>The standard approach for decomposing a system into an application and a number of DLLs involves creating a stub library for each DLL. This stub library is linked to the application at build time and acts as a proxy, resolving calls from the application to functions, data and resources in the DLL. The build process also puts information into the application’s EXE header to ensure these references are resolved by the DLL at runtime. Therefore when the operating system loads the application at runtime it obtains information about its dependences from the EXE header and subsequently loads the necessary DLL into memory (if not already present) before resolving all proxy references in the application to the read-only code, data and resources in the DLL’s memory space.</p>
    </body>
</html>